<?php
$hostname = "localhost";
$username = "rt_user";
$password = "rtpassword";
$strFlg = "";
$database = "rt_widgets";
$dbConnection = mysql_connect($hostname,$username,$password,$strFlg) or die('Can\'t connect'); 
mysql_select_db($database, $dbConnection) or die('can\'t connect to db');
if($_GET['type']=='video'){
    $query = mysql_query('SELECT * FROM tbl_video order by rank limit 10 ' ,$dbConnection) or die(mysql_error());
    $incr=0;
    $record = "";
    $arrRecords = array();
    while($record = mysql_fetch_object($query) ){
      $arrRecords[$incr] = $record;
      $incr++;
    }
    $arrdatavideo = array();
    for($i=0;$i<count($arrRecords);$i++){
        $arrdatavideo[$i]->video = $arrRecords[$i]->link;
        $arrdatavideo[$i]->rank = $arrRecords[$i]->rank;
        $arrdatavideo[$i]->desc = $arrRecords[$i]->description;
    }
    $arrdata = $arrdatavideo;
    echo(json_encode($arrdata));
}
?>